import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import Routers from './router';
import Vuex from 'vuex';
import Util from './libs/util';
import App from './app.vue';
import {get, post, fetchGrid } from './libs/header.js';
import 'iview/dist/styles/iview.css';
// import BaiduMap from 'vue-baidu-map';
// 配置百度UEditor
import '../static/UEditor/ueditor.config.js';
import '../static/UEditor/ueditor.all.min.js';
import '../static/UEditor/lang/zh-cn/zh-cn.js';
import '../static/UEditor/ueditor.parse.min.js';

Vue.use(VueRouter);
Vue.use(Vuex);

Vue.use(iView);

// axios
import axios from './libs/axios';
window.axios = axios;
Vue.prototype.$get = get;
Vue.prototype.$post = post;
Vue.prototype.$fetchGrid = fetchGrid;

// 路由配置
const RouterConfig = {
    mode: 'history',
    routes: Routers
};

const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    Util.title(to.meta.title);
    next();
});

router.afterEach(() => {
    iView.LoadingBar.finish();
    window.scrollTo(0, 0);
});

import store from './store';

// 谷歌地图
// import * as VueGoogleMaps from 'vue2-google-maps';
// Vue.use(VueGoogleMaps, {
//     load: {
//         // key: 'AIzaSyCDoZwHDtJ0GKx-U9Y-SZwgL_5vNDeDBKs'
//         key: 'AIzaSyBMax06DjAJoHnTK1HBZNLh3GBxBETJ7Vw',
//         libraries: 'places',
//     },
//     loadCn: true
// });

new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App)
});